package com.godofgamblers.hotelmanagementsystem.handler;

import com.godofgamblers.hotelmanagementsystem.pojo.Order;
import com.godofgamblers.hotelmanagementsystem.pojo.Order_item;
import com.godofgamblers.hotelmanagementsystem.pojo.User;
import com.godofgamblers.hotelmanagementsystem.service.Room_TypeService;
import com.godofgamblers.hotelmanagementsystem.service.UserCenterService;
import lombok.Data;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.*;

/**
 * @author Haonan
 * @date 2019/10/22 - 15:02
 */
@Controller
@Data
public class UserCenterHandler {
    @Autowired
    private UserCenterService userCenterService;
    @Autowired
    private Room_TypeService room_typeService;
    private List<Order> orders;
    private List<Order_item> order_items;



    //查看未支付的订单
    @RequestMapping("/checkUnpaid")
    @ResponseBody
    public List<Order> checkUnpaid(
            @RequestParam int user_id
    ) {
        orders = userCenterService.findUnpaidOrder(user_id);
        return orders;
    }

    // 查看未使用的订单项
    @RequestMapping("/checkUnused")
    @ResponseBody
    public List<Order_item> checkUnused(
            @RequestParam int user_id
    ){
        order_items = userCenterService.findUnusedOrderItem(user_id);
        return order_items;
    }

    // 找到房间的类型名字
    @RequestMapping("/findRoomTypeName")
    @ResponseBody
    public String findRoomTypeName(
            @RequestParam int room_type_id
    ) {
        System.out.println(room_type_id);
        String roomTypeName = room_typeService.selectRoomTypeNameById(room_type_id);
        return roomTypeName;
    }

    @RequestMapping("/checkComplete")
    @ResponseBody
    public List<Order_item> checkComplete(
            @RequestParam int user_id
    ) {
        order_items = userCenterService.findCompleteOrderItem(user_id);
        return order_items;
    }

    @RequestMapping("/checkUnrated")
    @ResponseBody
    public String checkUnrated() {
        return "";
    }
}
